package ssq

import (
	"aquaman/app/biz/lottery"
	"aquaman/app/infra/job"
	"aquaman/app/infra/log"
	"github.com/spf13/cobra"
	"context"
	"time"
)


var Command = &cobra.Command{
	Use: "ssq",
	Run: func(cmd *cobra.Command, args []string) {
		j, cleanup := Job()
		defer cleanup()

		j.Run(cmd.Context())
	},
}

func rate() *time.Ticker {
	return time.NewTicker(time.Hour)
}

func task(ticker *time.Ticker, ctxlogger log.CtxLogger,lotterySvc *lottery.Service)job.Task {
	return func(ctx context.Context) error {
		// todo
		interval := lotterySvc.HandleSSQSpider(ctx)
		if interval != 0 {
			ticker.Reset(time.Second * time.Duration(interval))
		}else  {
			ticker.Reset(time.Hour)
		}
		return nil
	}
}
